<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>原型继承实现</title>
</head>

<body>
  <script>
    // ============================== 原型继承 ==============================
    //属性
    function Person() {
      this.eyes=2
    }
     //方法
    Person.prototype.eat=function(){
      console.log(`eat`)
    }
    
    //构造函数
    function Man() {}
    function Woman() {}


   //需要把 Man.prototype赋值给Person的实例对象
    Man.prototype=new Person()
    Woman.prototype=new Person()  

  //细节处理
    Man.prototype.constructor=Man
    Woman.prototype.constructor=Woman

  //继承-借助于原型对象
    const zx=new Man()
    const xh=new Man()

    zx.eat()
    xh.eat()


  </script>
</body>

</html>